﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using Validate.Net;
using Validate.Net.Core;
using Validate.Net.Internals;

namespace Test
{
    class Program
    {
        static CustomPrompts Prompts { get; } = new CustomPrompts();
        static void Main(string[] args)
        {
            Console.WriteLine($"当前区域：{CultureInfo.CurrentUICulture}");

            UserModel user = new UserModel()
            {
                Account = "1000",
                Password = "",
                PasswordWhiteSpace = "    ",
                PasswordSkipWhiteSpace = "    ",
                Email = "77111.cn",
                ZipCode = "6572151",
                Chinese = "wjl",
                NegtiveInt = 1,
                PositiveInt = -2,
                Ip = "192.0.0.256",
                url = "https://www.baidu.com",
                CustomStr = "657215@",
                MaxLength = null,
                Age = 100,
                Letter = "www",
                MinLong = 0,
                AgeRange = 0,
                MinLength = "123456",
                QQ = "13155654521",
                IDCard = "503081199604061533",
                SocialCreditCode = "91350500611880326T",
                Pwd = "wjl1345",
                NonpositiveInt = -66.1,
                NonnegativeInt = 66.1,
            };

            Prompts.Set<RequiredAttribute>("必须填写内容 - 设置提示语");

            foreach (var result in user.Check())
            {
                Console.WriteLine($"属性 {result.Property.GetDescription() ?? result.Property.Name} 的值 {result.Prompts}");
                Console.WriteLine();
            }

            Console.WriteLine();

            CultureInfo.CurrentUICulture = CultureInfo.CreateSpecificCulture("en");
            Console.WriteLine($"当前区域：{CultureInfo.CurrentUICulture}");

            if (!user.Check(out IList<CheckedResults> results))
            {
                foreach (var result in results)
                {
                    Console.WriteLine($"属性 {result.Property.GetDescription() ?? result.Property.Name} 的值 {string.Join(" 且 ", result.Prompts)}");
                    Console.WriteLine();
                }
            }

            Console.WriteLine();

            TestMethod("");

            Console.ReadKey();
        }

        
        static void TestMethod([NotDefault] string str)
        {
            Console.WriteLine(str);
        }
    }
}
